package com.mit.web.util
{
	import com.mit.web.config.Constants;
	
	import mx.formatters.CurrencyFormatter;
	import mx.formatters.DateFormatter;
	import mx.resources.ResourceManager;
	
	public class DataFormatUtil
	{
		public function DataFormatUtil()
		{
		}
		
		public static function toGenderDisplayFormat(genderDBVal:String):String{
			if(genderDBVal == Constants.MALE)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,"label.gender.male");
			else if (genderDBVal == Constants.FEMALE)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,"label.gender.female");
			else
				return "";
			
		}
		
		public static function toString(date:Date, pattern:String):String{
			var formatter:DateFormatter = new DateFormatter();
			formatter.formatString = pattern;
			return formatter.format(date);
			
		}
		
		public static function toCurrencyStr(n:Number):String{
			var formatter:CurrencyFormatter = new CurrencyFormatter();
			formatter.currencySymbol = Constants.CURRENCY_SYMBEL;
			formatter.useThousandsSeparator = true;
			formatter.precision = 2;
			return formatter.format(n);
		}
		
		public static function toTaskStatusDisplayFormat(dbVal:String):String{
			if(dbVal == Constants.OPEN)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,'label.open');
			else if(dbVal == Constants.CLOSE)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,'label.close');
			else
				return "";
		}
		public static function toActiveStatusDisplayFormat(dbVal:String):String{
			if(dbVal == Constants.YES)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,'label.active');
			else if(dbVal == Constants.NO)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,'label.inactive');
			else
				return "";
		}
		public static function toYesNoStatusDisplayFormat(dbVal:String):String{
			if(dbVal == Constants.YES)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,'label.yes');
			else if(dbVal == Constants.NO)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,'label.no');
			else
				return "";
		}
		public static function toTemplateTypeDisplayFormat(dbVal:String):String{
			if(dbVal == Constants.TEMPLATE_SOFT)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,'label.softTemplate');
			else if(dbVal == Constants.TEMPLATE_HARD)
				return ResourceManager.getInstance().getString(Constants.BUNDLE_COMMON,'label.hardTemplate');
			else
				return "";
		}
	}
}